<!--
 * @Author: 叫我龟先生 yyxxkahhh@163.com
 * @Date: 2022-09-05 10:44:36
 * @LastEditors: 叫我龟先生 yyxxkahhh@163.com
<<<<<<< HEAD
 * @LastEditTime: 2022-09-05 17:14:02
=======
 * @LastEditTime: 2022-09-05 15:35:48
>>>>>>> add/demo
 * @FilePath: \git仓库\demo.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function Father(uname, age) {
            this.uname = uname
            this.age = age
            console.log(this);
            this.money = function () {
                console.log('我赚了一个小目标');
            }
        }
        // Father.prototype.money = function () {
        //     console.log('我赚了一个小目标');
        // }
        // console.log(Father);
        function Son(uname,age){
            Father.call(this,uname,age)
        }
        // console.log(son);
        // //把father的原型给儿子的原型
        // Son.prototype = father.prototype
        //把father的实例化给了son
        Son.prototype = new Father()
        //将Son.prototype的constructor属性指回Son构造函数
        Son.prototype.constructor = Son
        //给Son.prototype添加新的方法
        Son.prototype.exam = function(){
            console.log('今天考100分');
        }
        const son = new Son('ls', 18)
        const father = new Father('zs', 40)
        son.exam() 
    </script>
</body>

</html>